<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
  xmlns:system="clr-namespace:System;assembly=mscorlib"
  xmlns:dentalConverters="clr-namespace:DentalConfig.Converters;assembly=DentalConfig"
  xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Generic.xaml"/>
    <ResourceDictionary Source="../Brushes/MaterialDesign/MaterialDesignTheme.Theme.xaml"/>
    <ResourceDictionary Source="../NamedStyles/MaterialDesignTheme.NamedTextBlock.xaml"/>
    <ResourceDictionary Source="MaterialDesignTheme.Button.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <!-- TODO freeze, share -->
  <SolidColorBrush x:Key="AttentionToActionBrush" Color="Black" Opacity=".23"/>

  <converters:MathConverter Operation="Divide" x:Key="DivisionMathConverter"/>
  <converters:PointValueConverter x:Key="PointValueConverter"/>
  <dentalConverters:BrushToTransmittantBrushConverter x:Key="BrushToTransmittantBrushConverter"/>

  <Style x:Key="FocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="EllipseFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid x:Name="FocusGrid">
            <Canvas>
              <Ellipse Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}" Width="44" Height="44"  Canvas.Left="-8" Canvas.Top="-8" Opacity="0.12"/>
            </Canvas>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="SwitchCapsuleFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid>
            <Canvas>
              <Border Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}" CornerRadius="16" Width="48" Height="32" Canvas.Left="-8" Canvas.Top="-8" Opacity="0.12"/>
            </Canvas>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="HamburgerEllipseFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid>
            <Canvas>
              <Ellipse Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}" Width="44" Height="44" Canvas.Left="-4" Canvas.Top="-4" Opacity="0.12"/>
            </Canvas>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="OverlayFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Border CornerRadius="2" Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground, Converter={StaticResource BrushToTransmittantBrushConverter}, ConverterParameter=0.24}"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!--x:Shared="False"-->
  <wpf:PackIcon x:Key="CheckMarkIcon" Kind="Check" Width="24" Height="24" FlowDirection="LeftToRight"/>

  <Style x:Key="MaterialDesignActionToggleButton" TargetType="{x:Type ToggleButton}">
    <Style.Resources>
      <ResourceDictionary>
        <Style TargetType="wpf:PackIcon" BasedOn="{StaticResource {x:Type wpf:PackIcon}}">
          <Setter Property="Width" Value="20"/>
          <Setter Property="Height" Value="20"/>
        </Style>
        <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
      </ResourceDictionary>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{StaticResource EllipseFocusVisual}"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryForegroundBrush}"/>
    <Setter Property="Background" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource HighContrastPrimaryBrush}"/>
    <Setter Property="Width" Value="28"/>
    <Setter Property="Height" Value="28"/>
    <Setter Property="FontSize" Value="18"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth0"/>
    <Setter Property="wpf:ToggleButtonAssist.OnContent" Value="{StaticResource CheckMarkIcon}"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="0.23" Storyboard.TargetProperty="(UIElement.Opacity)"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="0"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="1"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="0"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Indeterminate">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="IndeterminateCheck"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid x:Name="OffGrid" RenderTransformOrigin=".5,.5" Background="{TemplateBinding BorderBrush}">
              <ContentPresenter
                ContentTemplate="{TemplateBinding ContentTemplate}"
                Content="{TemplateBinding Content}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                RecognizesAccessKey="False"
                FlowDirection="LeftToRight"/>
              <Grid.Clip>
                <EllipseGeometry
                  RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}"
                  RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}">
                  <EllipseGeometry.Center>
                    <MultiBinding Converter="{StaticResource PointValueConverter}">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                    </MultiBinding>
                  </EllipseGeometry.Center>
                </EllipseGeometry>
              </Grid.Clip>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OffScaleTransform" ScaleX="1" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
            <Grid x:Name="OnGrid" RenderTransformOrigin=".5,.5" Background="{TemplateBinding Background}">
              <ContentPresenter
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                RecognizesAccessKey="False"
                FlowDirection="LeftToRight"
                Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContent)}"
                ContentTemplate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContentTemplate)}"/>
              <Grid.Clip>
                <EllipseGeometry
                  RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}"
                  RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}">
                  <EllipseGeometry.Center>
                    <MultiBinding Converter="{StaticResource PointValueConverter}">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                    </MultiBinding>
                  </EllipseGeometry.Center>
                </EllipseGeometry>
              </Grid.Clip>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OnScaleTransform" ScaleX="0" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignActionLightToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignActionToggleButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignActionDarkToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignActionToggleButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignActionAccentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignActionToggleButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignActionMirrorToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignActionAccentToggleButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="{StaticResource DisabledOpacity}" Storyboard.TargetProperty="(UIElement.Opacity)"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ContentScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentGrid">
                        <LinearDoubleKeyFrame Value="0.7" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ContentScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentGrid">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0.7" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="0"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ContentScaleTransform" To="1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentGrid" To="1"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="0"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ContentScaleTransform" To="1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentGrid" To="0.7"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Indeterminate">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="IndeterminateCheck"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid x:Name="OffGrid" RenderTransformOrigin=".5,.5" Background="{TemplateBinding BorderBrush}">
              <Grid.Clip>
                <EllipseGeometry
                  RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}"
                  RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}">
                  <EllipseGeometry.Center>
                    <MultiBinding Converter="{StaticResource PointValueConverter}">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                    </MultiBinding>
                  </EllipseGeometry.Center>
                </EllipseGeometry>
              </Grid.Clip>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OffScaleTransform" ScaleX="1" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
            <Grid x:Name="OnGrid" RenderTransformOrigin=".5,.5" Background="{TemplateBinding Background}">
              <Grid.Clip>
                <EllipseGeometry
                  RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}"
                  RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}">
                  <EllipseGeometry.Center>
                    <MultiBinding Converter="{StaticResource PointValueConverter}">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" Converter="{StaticResource DivisionMathConverter}" ConverterParameter="2.0"/>
                    </MultiBinding>
                  </EllipseGeometry.Center>
                </EllipseGeometry>
              </Grid.Clip>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OnScaleTransform" ScaleX="0" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
            <Grid x:Name="ContentGrid" RenderTransformOrigin=".5,.5" Background="Transparent" Opacity="1">
              <ContentPresenter
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                RecognizesAccessKey="False"
                FlowDirection="LeftToRight"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                Content="{TemplateBinding Content}"/>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="ContentScaleTransform" ScaleX="1" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatFlipToggleButton" TargetType="{x:Type ToggleButton}">
    <Style.Resources>
      <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{StaticResource EllipseFocusVisual}"/>
    <Setter Property="Foreground" Value="#616161"/>
    <Setter Property="Background" Value="#e0e0e0"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Width" Value="44"/>
    <Setter Property="Height" Value="44"/>
    <Setter Property="FontSize" Value="18"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="8"/>
    <Setter Property="Margin" Value="-8"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid ClipToBounds="True" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Margin="{TemplateBinding Margin}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="0.23" Storyboard.TargetProperty="(UIElement.Opacity)"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="-1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform">
                        <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform">
                        <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0.1"/>
                        <LinearDoubleKeyFrame Value="-1" KeyTime="0:0:0.2"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="0"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="1"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OffScaleTransform" To="-1"/>
                    <DoubleAnimation Duration="0" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="OnScaleTransform" To="0"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid x:Name="OffGrid" RenderTransformOrigin=".5,.5" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
              <Grid.OpacityMask>
                <VisualBrush Stretch="None" Visual="{Binding ElementName=maskGrid}"/>
              </Grid.OpacityMask>
              <Rectangle Fill="{TemplateBinding BorderBrush}"/>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OffScaleTransform" ScaleX="-1" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
            <Grid x:Name="OnGrid" RenderTransformOrigin=".5,.5" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
              <Grid.OpacityMask>
                <VisualBrush Stretch="None" Visual="{Binding ElementName=maskGrid}"/>
              </Grid.OpacityMask>
              <Rectangle Fill="{TemplateBinding Background}"/>
              <Grid.RenderTransform>
                <ScaleTransform x:Name="OnScaleTransform" ScaleX="0" ScaleY="1"/>
              </Grid.RenderTransform>
            </Grid>
            <Grid Visibility="Hidden">
              <Grid Margin="{TemplateBinding Padding}" x:Name="maskGrid">
                <Viewbox>
                  <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="False"/>
                </Viewbox>
              </Grid>
            </Grid>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Cursor" Value="Hand"/>
            </Trigger>
            <!-- TODO <Trigger Property="IsFocused" Value="True"> <Setter Property="BorderBrush" TargetName="normal" Value="{Binding (Custom:ControlsHelper.FocusBorderBrush), RelativeSource={RelativeSource TemplatedParent}}"/> </Trigger> -->
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatFlipPrimaryToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatFlipToggleButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFlatFlipAccentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatFlipToggleButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignSwitchToggleButton" TargetType="{x:Type ToggleButton}">
    <Setter Property="FocusVisualStyle" Value="{StaticResource SwitchCapsuleFocusVisual}"/>
    <Setter Property="HorizontalContentAlignment" Value="Left"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryForegroundBrush}"/>
    <Setter Property="Background" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignLightBackground}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Padding" Value="0 1 0 0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <ControlTemplate.Resources>
            <SineEase x:Key="RippleEasingFunction" EasingMode="EaseInOut"/>
            <Storyboard x:Key="ShowRipple">
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" EasingFunction="{StaticResource RippleEasingFunction}" To="0.26" Duration="0"/>
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" EasingFunction="{StaticResource RippleEasingFunction}" From="1" To="2.5" Duration="0:0:0.2"/>
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" EasingFunction="{StaticResource RippleEasingFunction}" From="1" To="2.5" Duration="0:0:0.2"/>
            </Storyboard>
            <Storyboard x:Key="HideRipple">
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" EasingFunction="{StaticResource RippleEasingFunction}" To="0" Duration="0:0:0.3"/>
            </Storyboard>
          </ControlTemplate.Resources>
          <Viewbox Width="34" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="23.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <QuadraticEase EasingMode="EaseOut"/>
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
                        <EasingDoubleKeyFrame KeyTime="0" Value="23.5"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <QuadraticEase EasingMode="EaseOut"/>
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" Duration="0" To="23.5"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" Duration="0" To="0"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid>
              <Rectangle x:Name="Track" Fill="{DynamicResource MaterialDesignBody}" HorizontalAlignment="Left" Height="15" Margin="4.211,5,4.211,0" Stroke="{x:Null}" VerticalAlignment="Top" Width="40" RadiusY="7.5" RadiusX="7.5" Opacity="0.26"/>

              <Grid x:Name="ThumbHolder" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Ellipse x:Name="RippleThumb" Fill="{DynamicResource PrimaryHueLightBrush}" Height="25" Width="25" IsHitTestVisible="False" Opacity="0.26" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                  <Ellipse.RenderTransform>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                  </Ellipse.RenderTransform>
                </Ellipse>
                <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
                  <Ellipse
                    x:Name="Thumb"
                    Fill="{TemplateBinding BorderBrush}"
                    Stroke="{x:Null}"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Width="25"
                    Height="25"
                    Margin="0,0,0,0"
                    RenderTransformOrigin="0.5,0.5"
                    Effect="{DynamicResource MaterialDesignShadowDepth1}"></Ellipse>
                </AdornerDecorator>
                <ContentPresenter
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  Content="{TemplateBinding Content}"
                  Margin="{TemplateBinding Padding}"
                  x:Name="ContentPresenter"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                  RecognizesAccessKey="False"
                  FlowDirection="LeftToRight"/>
                <Grid.RenderTransform>
                  <TranslateTransform X="0" Y="0"/>
                </Grid.RenderTransform>
              </Grid>
            </Grid>
          </Viewbox>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="Thumb" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
              <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsChecked" Value="True"/>
                <Condition Property="wpf:ToggleButtonAssist.HasOnContent" Value="True"/>
              </MultiTrigger.Conditions>
              <Setter TargetName="ContentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContent)}"/>
              <Setter TargetName="ContentPresenter" Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContentTemplate)}"/>
            </MultiTrigger>
            <Trigger Property="IsChecked" Value="False">
              <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="Button.IsDefaulted" Value="true"/>
            <Trigger Property="IsMouseOver" Value="true"/>
            <Trigger Property="IsPressed" Value="true">
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource ShowRipple}"/>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource HideRipple}"/>
              </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter TargetName="Thumb" Property="Fill" Value="#BDBDBD"/>
              <Setter TargetName="Track" Property="Fill">
                <Setter.Value>
                  <SolidColorBrush Color="{DynamicResource MaterialDesignColorBody}" Opacity=".12"/>
                </Setter.Value>
              </Setter>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignSwitchLightToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignSwitchDarkToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignSwitchAccentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignLabelSwitchToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchAccentToggleButton}">
    <Style.Resources>
      <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{StaticResource SwitchCapsuleFocusVisual}"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Padding" Value="0 1 0 0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <ControlTemplate.Resources>
            <SineEase x:Key="RippleEasingFunction" EasingMode="EaseInOut"/>
            <Storyboard x:Key="ShowRipple">
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" EasingFunction="{StaticResource RippleEasingFunction}" To="0.26" Duration="0"/>
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" EasingFunction="{StaticResource RippleEasingFunction}" From="1" To="2.5" Duration="0:0:0.2"/>
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" EasingFunction="{StaticResource RippleEasingFunction}" From="1" To="2.5" Duration="0:0:0.2"/>
            </Storyboard>
            <Storyboard x:Key="HideRipple">
              <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" EasingFunction="{StaticResource RippleEasingFunction}" To="0" Duration="0:0:0.3"/>
            </Storyboard>
          </ControlTemplate.Resources>
          <DockPanel>
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="23.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <QuadraticEase EasingMode="EaseOut"/>
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
                        <EasingDoubleKeyFrame KeyTime="0" Value="23.5"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <QuadraticEase EasingMode="EaseOut"/>
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" Duration="0" To="23.5"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" Duration="0" To="0"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Viewbox DockPanel.Dock="Left" Width="34">
              <Grid>
                <Rectangle x:Name="Track" Fill="{DynamicResource MaterialDesignBody}" HorizontalAlignment="Left" Height="15" Margin="4.211,5,4.211,0" Stroke="{x:Null}" VerticalAlignment="Top" Width="40" RadiusY="7.5" RadiusX="7.5" Opacity="0.26"/>
                <Grid x:Name="ThumbHolder" HorizontalAlignment="Left" VerticalAlignment="Top">
                  <Ellipse x:Name="RippleThumb" Fill="{DynamicResource PrimaryHueLightBrush}" Height="25" Width="25" IsHitTestVisible="False" Opacity="0.26" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                    <Ellipse.RenderTransform>
                      <ScaleTransform ScaleX="1" ScaleY="1"/>
                    </Ellipse.RenderTransform>
                  </Ellipse>
                  <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
                    <Ellipse
                      x:Name="Thumb"
                      Fill="{TemplateBinding BorderBrush}"
                      Stroke="{x:Null}"
                      HorizontalAlignment="Center"
                      VerticalAlignment="Center"
                      Width="25"
                      Height="25"
                      Margin="0,0,0,0"
                      RenderTransformOrigin="0.5,0.5"
                      Effect="{DynamicResource MaterialDesignShadowDepth1}"></Ellipse>
                  </AdornerDecorator>
                  <Grid.RenderTransform>
                    <TranslateTransform X="0" Y="0"/>
                  </Grid.RenderTransform>
                </Grid>
              </Grid>
            </Viewbox>
            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="False"/>
          </DockPanel>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="Thumb" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="Button.IsDefaulted" Value="true"/>
            <Trigger Property="IsMouseOver" Value="true"/>
            <Trigger Property="IsPressed" Value="true">
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource ShowRipple}"/>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource HideRipple}"/>
              </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter TargetName="Thumb" Property="Fill" Value="#BDBDBD"/>
              <Setter TargetName="Track" Property="Fill">
                <Setter.Value>
                  <SolidColorBrush Color="{DynamicResource MaterialDesignColorBody}" Opacity=".12"/>
                </Setter.Value>
              </Setter>
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignHamburgerToggleButton" TargetType="{x:Type ToggleButton}">
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="FocusVisualStyle" Value="{StaticResource HamburgerEllipseFocusVisual}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Width" Value="37"/>
    <Setter Property="Height" Value="37"/>
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border Background="{TemplateBinding Property=Background}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState Name="Normal"/>
                <VisualState Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="0.23" Storyboard.TargetProperty="(UIElement.Opacity)"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
              <VisualStateGroup x:Name="CheckStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="Checked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="45"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.581"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="4.875"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.875"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-45"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.581"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="4.832"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-2.082"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle1">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.889"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle1">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="canvas">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-180"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Checked" To="Unchecked">
                    <Storyboard>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle2">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle1">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle1">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="canvas">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="45" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="0.581" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="4.875" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="1.875" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="-45" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="0.581" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="4.832" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="-2.082" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="0.889" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle1"/>
                    <DoubleAnimation Duration="0" To="-1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle1"/>
                    <DoubleAnimation Duration="0" To="-180" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="canvas"/>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle2"/>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="rectangle1"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle1"/>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="canvas"/>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Viewbox>
              <Canvas x:Name="canvas" Width="24" Height="24" RenderTransformOrigin="0.5,0.5">
                <Canvas.RenderTransform>
                  <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                  </TransformGroup>
                </Canvas.RenderTransform>
                <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Height="2" Canvas.Left="3" RadiusY="0" RadiusX="0" Canvas.Top="6" Width="18" RenderTransformOrigin="0.5,0.5">
                  <Rectangle.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform/>
                      <SkewTransform/>
                      <RotateTransform/>
                      <TranslateTransform/>
                    </TransformGroup>
                  </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle x:Name="rectangle1" Fill="{TemplateBinding Foreground}" Height="2" Canvas.Left="3" RadiusY="0" RadiusX="0" Canvas.Top="11" Width="18" RenderTransformOrigin="0.5,0.5">
                  <Rectangle.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform/>
                      <SkewTransform/>
                      <RotateTransform/>
                      <TranslateTransform/>
                    </TransformGroup>
                  </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle x:Name="rectangle2" Fill="{TemplateBinding Foreground}" Height="2" Canvas.Left="3" RadiusY="0" RadiusX="0" Canvas.Top="16" Width="18" RenderTransformOrigin="0.5,0.5">
                  <Rectangle.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform/>
                      <SkewTransform/>
                      <RotateTransform/>
                      <TranslateTransform/>
                    </TransformGroup>
                  </Rectangle.RenderTransform>
                </Rectangle>
              </Canvas>
            </Viewbox>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="Button.IsDefaulted" Value="true"/>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignContentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <!--<ControlTemplate.Resources> <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/> </ControlTemplate.Resources>-->
          <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Border
                x:Name="border"
                Background="{TemplateBinding Background}"
                BorderThickness="{TemplateBinding BorderThickness}"
                BorderBrush="{TemplateBinding BorderBrush}"
                CornerRadius="2"
                Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"/>
            </AdornerDecorator>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              x:Name="contentPresenter"
              Opacity="1"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="contentPresenter" Property="Opacity" Value="1"/>
              <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Border
                x:Name="border"
                Background="{TemplateBinding Background}"
                BorderThickness="{TemplateBinding BorderThickness}"
                BorderBrush="{TemplateBinding Background}"
                CornerRadius="2"/>
            </AdornerDecorator>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              x:Name="contentPresenter"
              Opacity="1"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True"/>
                <Condition Property="IsChecked" Value="False"/>
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatContentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid>
            <ContentPresenter
              x:Name="contentPresenter"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              Margin="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter.RenderTransform>
                <TranslateTransform X="60000" Y="60000" /> <!-- We use the content presenter as mask, render it offscreen -->
              </ContentPresenter.RenderTransform>
            </ContentPresenter>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}"/>
            <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Width="{Binding ElementName=contentPresenter, Path=ActualWidth}" Height="{Binding ElementName=contentPresenter, Path=ActualHeight}">
              <Rectangle.OpacityMask>
                <VisualBrush TileMode="None" Stretch="None" Visual="{Binding ElementName=contentPresenter}"/>
              </Rectangle.OpacityMask>
            </Rectangle>
            <wpf:Ripple
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatNoFillToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatToggleButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Border
                x:Name="border"
                Background="{TemplateBinding Background}"
                BorderThickness="{TemplateBinding BorderThickness}"
                BorderBrush="{TemplateBinding Background}"
                CornerRadius="2"/>
            </AdornerDecorator>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              x:Name="contentPresenter"
              Opacity="1"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True"/>
                <Condition Property="IsChecked" Value="False"/>
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignOutlinedContentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignOutlinedOverlayButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid>
            <ContentPresenter
              x:Name="contentPresenter"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Margin="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter.RenderTransform>
                <TranslateTransform X="60000" Y="60000" /> <!-- We use the content presenter as mask, render it offscreen -->
              </ContentPresenter.RenderTransform>
            </ContentPresenter>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
            <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Width="{Binding ElementName=contentPresenter, Path=ActualWidth}" Height="{Binding ElementName=contentPresenter, Path=ActualHeight}">
              <Rectangle.OpacityMask>
                <VisualBrush TileMode="None" Stretch="None" Visual="{Binding ElementName=contentPresenter}"/>
              </Rectangle.OpacityMask>
            </Rectangle>
            <wpf:Ripple
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
              <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignOutlinedFillContentToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignOutlinedOverlayButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              x:Name="contentPresenter"
              Opacity="1"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
              <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{DynamicResource SecondaryAccentBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignStatusBarToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignOutlinedOverlayButton}">
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
    <Setter Property="Background" Value="{DynamicResource Dentalshare.Status.Arrow}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid>
            <ContentPresenter
              x:Name="contentPresenter"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Margin="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter.RenderTransform>
                <TranslateTransform X="60000" Y="60000" /> <!-- We use the content presenter as mask, render it offscreen -->
              </ContentPresenter.RenderTransform>
            </ContentPresenter>
            <Border Background="{TemplateBinding Background}" x:Name="border"/>
            <Grid x:Name="focusBackground" Background="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BrushToTransmittantBrushConverter}, ConverterParameter=0.12}" Visibility="Collapsed"/>
            <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Width="{Binding ElementName=contentPresenter, Path=ActualWidth}" Height="{Binding ElementName=contentPresenter, Path=ActualHeight}">
              <Rectangle.OpacityMask>
                <VisualBrush TileMode="None" Stretch="None" Visual="{Binding ElementName=contentPresenter}"/>
              </Rectangle.OpacityMask>
            </Rectangle>
            <wpf:Ripple
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Visibility" TargetName="focusBackground" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignFlatContentToggleButton}" TargetType="{x:Type ToggleButton}"/>

</ResourceDictionary>
